package com.marchsoft.controller;

import com.marchsoft.common.advice.CommonExceptionHandler;
import com.marchsoft.domain.Group;
import com.marchsoft.service.IGroupService;
import com.marchsoft.vo.GroupExtra;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * class description：
 * author：rsw
 * Date: 2019/11/17
 * Time: 11:00
 **/
@RestController
@RequestMapping("group")
public class GroupController extends CommonExceptionHandler {

    @Autowired
    private IGroupService groupService;

    /**
     * 查询所有小组的信息（包含指导老师的信息）
     * @return
     */
    @RequestMapping("/query-all")
    public ResponseEntity<List<GroupExtra>> queryGroupAll(){
        return ResponseEntity.ok(groupService.queryGroupAll());
    }

    /**
     * 根据小组id查询其信息（包含老师信息）
     * @param gid 小组id
     * @return 一条小组信息
     */
    @RequestMapping("/query-one")
    public ResponseEntity<GroupExtra> queryGroupByGid(Integer gid){
        return ResponseEntity.ok(groupService.queryGroupByGid(gid));
    }

}

